<?php
	
	if(isset($_GET['loai']))
	{
		$nguoidung = new nguoidungbs();
		
		$MaND = $_GET['id'];
		$loai = $_GET['loai'];
		$nguoidung->MaNguoiDung = $MaND;
		$danhsach = $nguoidung->GetList();
		$QuyenHan = $danhsach[0]['QuyenHan'];
		if($QuyenHan>=1 && $QuyenHan<=3)
		{
			if($loai == 1)
				$QuyenHan-- ;
			elseif($loai == 2)
				$QuyenHan++;
			elseif($QuyenHan == 3 && $loai == 1)
				$QuyenHan--;
			elseif($QuyenHan == 1 && $loai == 2)
				$QuyenHan--;
		
		$nguoidung->QuyenHan = $QuyenHan;
		
		$kq = $nguoidung->Active();
		
		if($kq)
			header("Location: index.php?do=nguoidung");
		else
			ThongBaoLoi("Lỗi truy vấn!");
		}
		else
		{
			echo "<script>
				alert('Quyền quá giới hạn cho phép');
			</script>";
		}
	}
	elseif(isset($_GET['khoa']))
	{
		$nguoidung = new nguoidungbs();
		$MaND = $_GET['id'];
		$Khoa = $_GET['khoa'];
		$nguoidung->MaNguoiDung = $MaND;
		$nguoidung->Khoa = $Khoa;
		
		$kq = $nguoidung->Active();
		
		if($kq)
			header("Location: index.php?do=nguoidung");
		else
			ThongBaoLoi("Lỗi truy vấn!");
	}
	else
	{
		header("Location: index.php?do=nguoidung");
	}
?>